package com.ganbo.stock.task;

import com.ganbo.stock.config.StockJobSwitchConfig;
import com.ganbo.stock.service.impl.IdeaService;
import com.ganbo.stock.service.impl.StockIdeaService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * 定时维护版块和版块跟股票的关联关系信息
 *
 * @Author: ganbo
 * @Date: 2020/12/28 15:38
 */

@Component
@Slf4j
public class IdeaJob {


    @Autowired
    IdeaService ideaService;
    @Autowired
    StockIdeaService stockIdeaService;
    @Autowired
    StockJobSwitchConfig switchConfig;


    @Scheduled(cron = "*/5 * * * * ?")
    public void updateStockIdeaTask() {
        if (switchConfig.isIdeaJob()) {
            log.info("定时更新版块关联表 start.");
            stockIdeaService.updateStockIdea();
            log.info("定时更新版块关联表 end.");
        }
    }


}
